package IO;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

/**
 * InputStreamReader/OutputStreamWriter 用来实现将字节流转化成字符流
 */

public class ConvertStream {
    public static void main(String[] args) {
        BufferedReader br = null;
        BufferedWriter bw = null;
        try{
            br = new BufferedReader(new InputStreamReader(System.in));
            bw = new BufferedWriter(new OutputStreamWriter(System.out));

            while(true){
                bw.write("请输入:");
                bw.flush();
                String str = br.readLine();
                if(str.equals("exit")) {
                    bw.write("退出程序");
                    bw.flush();
                    break;
                }
                bw.write("您输入的是："+str);
                bw.newLine();
                bw.flush();
            }
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            try{
                if(br != null){
                    br.close();
                }
                if(bw != null){
                    bw.close();
                }
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }
}
